package com.ejuornal.action;

import java.io.ByteArrayInputStream;

import com.ejuornal.util.RandomNumUtil;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class RandomNumAction extends ActionSupport{
    private static final long serialVersionUID = 1L;
    private RandomNumUtil randomNum;
    private ByteArrayInputStream inputStream;
    public ByteArrayInputStream getInputStream() {
        return inputStream;
    }
    public void setInputStream(ByteArrayInputStream inputStream) {
        this.inputStream = inputStream;
    }
    public RandomNumUtil getRandomNum() {
        return randomNum;
    }
    public void setRandomNum(RandomNumUtil randomNum) {
        this.randomNum = randomNum;
    }
    
    public String execute() throws Exception{
        randomNum = new RandomNumUtil(70,20,4,24);
        this.setInputStream(randomNum.getInputStream());
        ActionContext.getContext().getSession().put("random", randomNum.getRandomCode()); 
        return SUCCESS;
    }

    public String goRegister(){
        return "success";
    }
}
